﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private string loc;//Location, activity, Social context
        private string act;
        private string con;
        private List<string> loc_list;//List of previously used location, activity and
        private List<string> act_list;//social context
        private List<string> con_list;
        public Form1()
        {
            InitializeComponent();
            
            //Declare new sensors objects
            TimeSensor ts = new TimeSensor();
            ProcessSensor p = new ProcessSensor();
            ApplicationSensor a = new ApplicationSensor();
            iTunesSensor iT = new iTunesSensor();
            VolumeSensor v = new VolumeSensor();
            IESensor ie = new IESensor();
            USBSensor usb = new USBSensor();
            InterfaceSensor ins = new InterfaceSensor();
            WIFISensor w = new WIFISensor();

            List<Sensor> sensorlist = new List<Sensor>();

            sensorlist.Add(a);
            sensorlist.Add(v);
            sensorlist.Add(ie);
            sensorlist.Add(ins);
            sensorlist.Add(iT);
            sensorlist.Add(p);
            sensorlist.Add(ts);
            sensorlist.Add(usb);
            sensorlist.Add(w);

            SensorDisplay SD = new SensorDisplay(sensorlist);//Class that displays the sensors
            datagrid.DataSource = SD.sensorlist;
            ts.Attach(SD);
            p.Attach(SD);
            p.Attach(iT);//ProcessSensor notifies iTunesSensor
            p.Attach(ie);//ProcessSensor notifies IESensor
            p.Attach(a);
            iT.Attach(SD);
            v.Attach(SD);
            ie.Attach(SD);
            usb.Attach(SD);
            ins.Attach(SD);
            w.Attach(SD);
            a.Attach(SD);

            loc = "Collabolab";
            act = "Programming";
            con = "With Coworkers";
            predictionsSub1.Text = loc;
            predictionsSub2.Text = act;
            predictionsSub3.Text = con;
            loc_list = new List<string>();
            act_list = new List<string>();
            con_list = new List<string>();
            loc_list.Add(loc);
            act_list.Add(act);
            con_list.Add(con);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
        private void Form1_Resize(object sender, EventArgs e)
        {
            if (FormWindowState.Minimized == WindowState)
                Hide();
        }

        private void Icon_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Show();
            WindowState = FormWindowState.Normal;
            
        }

        private void ContextMenu_Opening(object sender, CancelEventArgs e)
        {

        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void Restore_Click(object sender, EventArgs e)
        {
            Show();
            WindowState = FormWindowState.Normal;
        }

        private void Hide_Click(object sender, EventArgs e)
        {
                Hide();
        }

        private void datagrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void correctPrediction_Click(object sender, EventArgs e)
        {
            Training t = new Training();
            t.MyParentForm = this;
            if (t.ShowDialog() == DialogResult.OK)
            {
                loc = t.location;
                act = t.activity;
                con = t.context;
                predictionsSub1.Text = loc;
                predictionsSub2.Text = act;
                predictionsSub3.Text = con;

                if (!con_list.Contains(con)) con_list.Add(con);
                if (!act_list.Contains(act)) act_list.Add(act);
                if (!loc_list.Contains(loc)) loc_list.Add(loc);
                
                //MessageBox.Show(t.boxcontents);
            }
        }

        private void dfsToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
        public string getLocation()
        {
            return loc;
        }
        public string getActivity()
        {
            return act;
        }
        public string getContext()
        {
            return con;
        }
        public List<string> getContextList()
        {
            return con_list;
        }
        public List<string> getActivityList()
        {
            return act_list;
        }
        public List<string> getLocationList()
        {
            return loc_list;
        }
    }
}
